home *** CD-ROM | disk | FTP | other *** search
- /*-
- * XDNAME.C
- *
- * Give info about the file names used for tracks.
- *
- * $Id: xdname.c,v 1.3 1995/04/08 20:23:48 Rhialto Exp $
- * $Log: xdname.c,v $
- * Revision 1.3 1995/04/08 20:23:48 Rhialto
- * Add/correct version strings.
- *
- * Revision 1.2 1993/11/08 13:18:19 Rhialto
- * Add RCS tags.
- *
- * This code is (C) Copyright 1993,1995 by Olaf Seibert. All rights reserved.
- * May not be used or copied without a licence.
- -*/
- #include "xpkdisk.h"
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <ctype.h>
-
- static const char idString[] = "\0$VER: xdName " STR(VERSION) "." STR(REVISION) "\r\n";
- static const char rcsId[] = "$Id: xdname.c,v 1.3 1995/04/08 20:23:48 Rhialto Exp $";
- static const char OldFile[]= "Track%03x";
-
- #define HASHTABLESIZE 72 /* Must be less than 13*13 */
-
- void
- OldName(char *filename, int track)
- {
- sprintf(filename, OldFile, track);
- }
-
- int
- main(int argc, char **argv)
- {
- char oldname[64];
- char newname[64];
- int new2old = 0;
- int number = 0;
- int maxtrack;
- int hash;
- int i;
-
- if (argc < 2) {
- usage:
- printf("Usage: XDName [-r] [-n] <track>\n");
- exit(10);
- }
-
- while (argv[1][0] == '-') {
- switch (argv[1][1]) {
- case 'r':
- new2old = 1;
- break;
- case 'n':
- number = 1;
- break;
- default:
- goto usage;
- }
- argv++;
- argc--;
- }
- maxtrack = strtol(argv[1], NULL, 0);
-
- if (number) {
- NewName(newname, maxtrack);
- hash = Hash(strrchr(newname, '/') + 1) % HASHTABLESIZE;
- printf("Track %d is %s ; hash = %d\n", maxtrack, newname, hash);
-
- return 0;
- }
-
- printf("failat 31\n");
- for (i = 0; i <= maxtrack; i++) {
- if (!new2old && i % HASHTABLESIZE == 0) {
- NewName(newname, i);
- *strrchr(newname, '/') = '\0';
- hash = Hash(newname) % HASHTABLESIZE;
- printf("makedir %s ; hash = %d\n", newname, hash);
- }
- OldName(oldname, i);
- NewName(newname, i);
- if (new2old) {
- hash = Hash(oldname) % HASHTABLESIZE;
- printf("rename %s to %s ; hash = %d\n", newname, oldname, hash);
- } else {
- hash = Hash(strrchr(newname, '/') + 1) % HASHTABLESIZE;
- printf("rename %s to %s ; hash = %d\n", oldname, newname, hash);
- }
- }
- return 0;
- }
-